package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Goods;
import com.atguigu.jxc.entity.GoodsType;
import com.atguigu.jxc.service.GoodsTypeService;
import com.atguigu.jxc.util.R;
import com.atguigu.jxc.vo.GoodsTypeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/goodsType")
public class GoodsTypeController {

    @Autowired
    private GoodsTypeService goodsTypeService;

    @PostMapping("/loadGoodsType")
    public List getCatalog(){
        List<Map> goodsTypes = goodsTypeService.getCatalog();
        return goodsTypes;
    }

    @PostMapping("/save")
    public ServiceVO save(String goodsTypeName,Integer pId){
        goodsTypeService.save(goodsTypeName,pId);
        return new ServiceVO(100,"添加成功");
    }

    @PostMapping("/delete")
    public ServiceVO delete(Integer  goodsTypeId){
        goodsTypeService.delete(goodsTypeId);
        return new ServiceVO(100,"删除成功");
    }
}
